BlitImageAlphaMultImage
BlitImageAlphaMultImage ThisImage, Xpos, Ypos, BlendImage
 
Parameters:

    ThisImage = The Index of the image you wish to draw
    Xpos = The X coordinate to draw this image
    Ypos = The Y coordinate to draw this image
    BlendImage = The index of the image to you wish to Alpha Mult from the primary image before drawing
Returns: NONE
 

     BlitImageAlphaMultImage is similar to the DrawImage function, except it has post processing. What it does, is it takes two images (of the same size) and uses Alpha Multiplication to blend them together before drawing them. The ouotput Pixels are calculated by Multipling pixels from the blend image with the primary image. So the blend image becomes a light map. Neither image is modified during the process.

      To create equivalent functionally, you'd need three images. The two images you wish to draw blended and third to store the temporary blended state. So we'd first copy the src image #1 to image 3, then blend src image 2 onto image 3 and finally draw image 3 to it's destination.


      The combined processing is not just to save you a few lines of code, it's actually a more optimal way of performing this action.



FACTS:


     * BlitImageAlphaMultImage is only intend for drawing FX or AFX formatted surfaces.

     * BlitImageAlphaMultImage doesn't support mask & alpha channel transparency.



 
Example Source: Download This Example
; Inlude the Blit Image functions
  #Include "BlitImage"
  
; Create an FX image the size of the screen
  MyImage=NewFXImage(GetScreenWidth(),GetScreenHeight())
  
  
; Create a second  FX image the size of the screen
; we'll be using to blend with our other image
  Backdrop=NewFXImage(GetScreenWidth(),GetScreenHeight())
  
; fill the backdrop with something so we can see it
  Tile=LoadNewFxImage("..\../Media/bg22.jpg")
  RenderToImage Backdrop
  TileImage Tile,0,0,false
  
  
; Set Fps of the program
  SetFPS 30
  
; enable Vsync to remove any tearing from the refresh
  ScreenVsync on
  
  
  Col=$f08040
  
  
; Start of Demo loop
  Do
     
   ; redirect all drawing to this image
     RenderToImage MyImage
     
     
     If LeftMouseButton()<>0 Then Col=RndRGB()
     Cls RGB(0,0,0)
     
   ; draw a circle at the mouses current position
     
     Draw_Light(MouseX(),MouseY(),250,Col)
     
     
   ; redirect all drawing to screen back buffer
     RenderToScreen
     
   ; To do combined Blit (copy) our Image.  This
   ; version multiples the pixels in the blend
   ; image (MyImage) with the backdrop. So it's
   ; using the blend image as light map.
     
     BlitImageAlphaMultImage(BackDrop,0,0,MyImage)
     
     
   ; Display Message
     Text 0,0,"Using BlitImageAlphaMultImage as a light Map"
     Text 0,20,"Left Mouse to change light colour"
     
   ; flip the back buffer to the front, so the user can see it
     Sync
     
  Loop
  
  
  
Function Draw_Light(X#,y#,Radius,Colour=$ffffff)
  
  Colour2=RGBFade(Colour,25)
  
  Edges=12
  steps#=360.0/Edges
  InkMode 1
  For lp=0 To Edges-1
     Angle1#=lp*Steps#
     Angle2#=WrapAngle(Angle1#,Steps#)
     
     x1#=x#+CosRadius(angle1#,Radius)
     y1#=y#+SinRadius(angle1#,Radius)
     
     x2#=X#+CosRadius(angle2#,Radius)
     y2#=y#+SinRadius(angle2#,Radius)
     
     GouraudTri x1#,y1#,Colour2,x2#,y2#,Colour2,x#,y#,Colour
     
  Next
  InkMode 1
  
  EndFunctio
 
Related Info: BlitImageAlpha50Colour | BlitImageClear | Box | DrawAlphaImage | DrawImage | InkMode :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com